package com.sixmac.platform.controller;

import com.sixmac.common.base.BaseController;
import com.sixmac.core.plugins.dao.Blade;
import com.sixmac.core.toolbox.Paras;
import com.sixmac.module.Area;
import com.sixmac.module.City;
import com.sixmac.module.Province;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


/**
 * Created by 杨春 on 2017/11/28.
 */
@Controller
@RequestMapping("/provinceCityArea/")
public class ProvinceCityAreaController extends BaseController {


    @ResponseBody
    @RequestMapping("/findProvince")
    public List<Province> findProvince() {
        Blade provinceBlade = Blade.create(Province.class);
        return provinceBlade.findAll();
    }

    @ResponseBody
    @RequestMapping("/findCity")
    public List<City> findCity(String provinceCode) {
        Blade cityBlade = Blade.create(City.class);
        return cityBlade.findBy("provinceCode = #{provinceCode} ", Paras.create().set("provinceCode", provinceCode));
    }

    @ResponseBody
    @RequestMapping("/findArea")
    public List<Area> findArea(String cityCode) {
        Blade areaBlade = Blade.create(Area.class);
        return areaBlade.findBy("cityCode = #{cityCode} ", Paras.create().set("cityCode", cityCode));
    }
}
